<meta name="content-type" content="text/html; charset=UTF-8" />
<!--#var(Status status, PaginatedList<Status> statusList)-->
<!--
#set(
pager = statusList.pager,
totalResults = pager.getCountOfTotalResults(),
totalPages = pager.getCountOfTotalPages() * 1,
pageSize = pager.pageSize,
pageNo = pager.pageNo,
prePageNo = pager.getPrevPageNo(),
nextPageNo = pager.getNextPageNo()
)
-->
<div class="panel-heading panel-result-title">
	<h3 class="panel-title">查询结果</h3>
	<div class="btn-group btn-group-sm btn-gp-default">
		<button id="btn_edit" type="button"
			class="btn btn-default panel-radius-left" onclick="window.location.href='yueyogaAdmin/toAddStatus.jhtml'">创建</button>
		<button id="btn_edit" type="button"
			class="btn btn-default panel-radius-none" onclick="updateStatus()">修改</button>
		<button id="btn_delete" type="button"
			class="btn btn-default panel-radius-right" onclick="deleteStatus()">删除</button>
	</div>
</div>
<!--#if(totalResults== null || totalResults==0)-->
<div class="panel-body">
	<p>没有符合条件的数据</p>
</div>
<!--#else-->
<table class="table table-bordered table-hover table-condensed">
	<tbody>
	<tr class="active">
		<th style="text-align:center;" width="5%"><input type="checkbox" onclick="selectAll()" name="controlAll" style="controlAll" id="controlAll"></th>
		<th style="text-align:center;" width="15%">状态编号</th>
		<th style="text-align:center;" width="20%">状态名称</th>
		<th style="text-align:center;" width="20%">状态类型</th>
		<th style="text-align:center;" width="40%">上级状态</th>
	</tr>
	</tbody>
	<tbody>
	<!--#foreach(status in statusList)-->
	<tr>
		<td align="center"><input type="checkbox" name="selected" value="${status.id}"></td>
		<td align="center">${status.code}</td>
		<td align="center">${status.name}</td>
		<td align="center">${status.type}</td>
		<td align="center">${status.parentcode}</td>
	<tr>
	<!--#end-->
	</tbody>
</table>
<!-- 列表分页 -->
<div class="paging-page">$!{include("paging_page.html")}</div>
<!--#end-->
<script>
function selectAll(){
	var checklist = document.getElementsByName("selected");
	if(document.getElementById("controlAll").checked){
		for(var i=0;i<checklist.length;i++){
			checklist[i].checked = 1;
		}
	}else{
		for(var j=0;j<checklist.length;j++){
			checklist[j].checked = 0;
		}
	}
}
function deleteStatus(){
	var checklist = document.getElementsByName("selected");
	var ids="";
	for(var i=0;i<checklist.length;i++){
		if(checklist[i].checked){
			ids=ids+checklist[i].value+",";
		}
	}
	if(ids==""){
		alert("请选择要删除的行");
	}else{
		if(confirm('确定要删除吗？')){
			ids = ids.substring(0, ids.length - 1);
			var url = "yueyogaAdmin/deleteStatus.jhtml?ids="+ids;
			$.post(url,function(response){
				if(response){
					alert("删除成功!");
					window.location.href="yueyogaAdmin/findStatusList.jhtml"; 
				}else{
					alert("删除失败!");
				}
			}, "json");
		}
	}
}
function updateStatus(){
	var checklist = document.getElementsByName("selected");
	var id="";
	var count=0;
	for(var i=0;i<checklist.length;i++){
		if(checklist[i].checked){
			id=id+checklist[i].value;
			count++;
		}
	}
	if(count==1){
		window.location.href="yueyogaAdmin/toEditStatus.jhtml?id="+id;
	}else{
		alert("请选择一行进行编辑");
	}
}
function changePage(value) {
	value = value * 1;
	var totalPages = '${totalPages}';
	if (value > totalPages) {
		value = totalPages;
	} else if (value < 1) {
		value = 1;
	}
	$("#txtPageNumber").val(value);
	goToPage(value);
}
function goToPage(pageNo) {
	$("#hidPageNo").val(pageNo);
	document.taskForm.submit();
}
</script>